package main

import (
	"fmt"
	"log"
	"net"
	"os"
	"time"
)

func server(port string) {
	hostPort := "0.0.0.0:" + port
	l, e := net.Listen("tcp4", hostPort)
	if e != nil {
		log.Println(e.Error())
		os.Exit(0)
	}
	for {
		conn, err := l.Accept()
		if err != nil {
			log.Println(err.Error())
			os.Exit(0)
		}
		time.Sleep(time.Second * 20000)
		handle(conn)
		time.Sleep(time.Second * 100000)
	}
}

func handle(conn net.Conn) {
	// defer conn.Close()
	b := make([]byte, 5100, 5100)
	for i := 0; ; i++ {
		conn.Read(b)
		fmt.Println(i + 1)
		time.Sleep(time.Second * 1)
	}
}
